#!/bin/sh

ver_old="$2"

if [ "$(apk version -t "$ver_old" '2.0.0-r0')" = '<' ]; then
	cat <<-EOF >&2
	Version 2.0 of postsrsd is a complete rewrite. The configuration comes
	from a configuration file instead of command line arguments to the daemon.
	Make sure you migrate your configuration to /etc/postsrsd/postsrsd.conf.
	See: https://github.com/roehling/postsrsd/releases/tag/2.0.0
	EOF

	if ! [ -d /var/lib/postsrsd ] && id postsrsd >/dev/null 2>&1; then
		current_uid=$(id -u postsrsd)
		current_gid=$(id -g postsrsd)
		deluser postsrsd

		addgroup -S postsrsd -g "$current_gid" 2>/dev/null
		adduser -S -D -h /var/lib/postsrsd -s /bin/false -u "$current_uid" -G postsrsd -g postsrsd postsrsd 2>/dev/null
	fi
fi



exit 0
